package com.example.mq;

import com.example.pojo.Parking;
import com.example.service.IParkingEsService;
import com.example.service.IParkingService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: gxcwhd
 * @BelongsPackage: com.example.mq
 * @Author: LJ
 * @CreateTime: 2020-08-24 16:25
 * @Description:
 */
@Component
public class ParkingOptListener {

//    @Autowired
//    IParkingEsService parkingEsService;
//
//    @Autowired
//    IParkingService parkingService;
//
//    @RabbitListener(queuesToDeclare = @Queue("es.mysql.copy.data"))
//    public void copyDataToEsFromMysql(String msg){
//        //解析消息
//        String[] split = msg.split("-");
//        //获取订单id
//        String parkingId = split[0];
//        //获取操作类型
//        String type = split[1];
//
//        if (type.equals("insert") || type.equals("update")){
//            //在es业务类中 没有update这个方法
//            //它将 add和update 合并了  取决于实体类中有没有主键
//            //从数据库中 通过id 获取 订单完整数据(后期可以用redis优化)
//            Parking parking = parkingService.getParkingById(parkingId);
//            parkingEsService.save(parking);
//        }else if(type.equals("delete")){
//            parkingEsService.deleteById(parkingId);
//        }
//    }
}
